<template>
  <el-form label-position="right" label-width="80px">
    <el-row :gutter="8">
      <el-col :span="8">
        <el-form-item label="调用指令" required>
          <el-input v-model="dictInfo.callCmd" :disabled="!$Util.isEmpty(dictInfo.dictId)" />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="字典名称" required>
          <el-input v-model="dictInfo.dictName" />
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="字段备注">
          <el-input v-model="dictInfo.dictNote" />
        </el-form-item>
      </el-col>
    </el-row>
    <el-form-item label-width="0" style="text-align: center">
      <el-button-group>
        <el-button type="success" icon="el-icon-check" @click="saveDict">{{ dictInfo.dictId ? '更新' : '保存' }}</el-button>
      </el-button-group>
      <app-dict-data v-if="dictInfo.dictId" :dict-info="dictInfo" />
    </el-form-item>
  </el-form>
</template>

<script>
import DictData from "@/views/system/db/dict/DictData";
import AppDictData from "@/views/system/app/dict/AppDictData";
export default {
  name: "AppDictInfo",
  components: {AppDictData, DictData},
  props: {
    dictInfo: {
      type: Object,
      default: function () {
        return {}
      }
    }
  },
  data(){
    return {
      loading: false
    }
  },
  methods: {
    saveDict() {
      this.loading = true
      this.$post('labDict/save', this.dictInfo)
          .then(res => {
            this.$resultMsg(this, res)
            if (res.code === 200) {
              this.$set(this.dictInfo, 'dictId',res.data.dictId)
              this.$emit('save', this.dictInfo)
            }
            setTimeout(() => {
              this.loading = false
            }, 200)
          })
    }
  }
}
</script>

<style scoped>

</style>
